﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace rbdesign
{
    class StartDatabaseStructure
    {
        public static bool FillDatabase()
        {
            FillUserTable();
            FillSubjectTable();
            FillTopicTable();
            FillArticleTable();

            return true;
        }

        private static bool FillUserTable()
        {
            Model.ModelCRUD.InsertUpdateDelete("INSERT INTO tblUser(username,password,email,birthdate,sex,interests) Values('Omer','12345','omer@gmail.com','" + DateTime.Today.ToString() + "','M','Cinema')");
            Model.ModelCRUD.InsertUpdateDelete("INSERT INTO tblUser(username,password,email,birthdate,sex,interests) Values('Shahaf','67890','shahaf@yahoo.com','" + DateTime.Today.ToString() + "','M','Parties')");
            Model.ModelCRUD.InsertUpdateDelete("INSERT INTO tblUser(username,password,email,birthdate,sex,interests) Values('Koskas','24680','koskas@msn.com','" + DateTime.Today.ToString() + "','M','Parties,Cinema')");

            return true;
        }

        private static bool FillSubjectTable()
        {
            Model.ModelCRUD.InsertUpdateDelete("INSERT INTO tblSubject(name) Values('Parties')");
            Model.ModelCRUD.InsertUpdateDelete("INSERT INTO tblSubject(name) Values('Cinema')");

            return true;
        }

        private static bool FillTopicTable()
        {
            Model.ModelCRUD.InsertUpdateDelete("INSERT INTO tblTopic(author,subject,message,date) Values(3,'Subject #1','This is the first topic ever','" + DateTime.Today.ToString() + "')");
            Model.ModelCRUD.InsertUpdateDelete("INSERT INTO tblTopic(author,subject,message,date) Values(1,'Subject #2','Just another topic to set things right under a different subject','" + DateTime.Today.ToString() + "')");
            Model.ModelCRUD.InsertUpdateDelete("INSERT INTO tblTopic(author,subject,message,date) Values(1,'Another Subject','Writing means everything to me, or not?!','" + DateTime.Today.ToString() + "')");
            Model.ModelCRUD.InsertUpdateDelete("INSERT INTO tblTopic(author,subject,message,date) Values(1,'Yet plenty to do','World Wide Web is a web that is as wide as the world...','" + DateTime.Today.ToString() + "')");

            return true;
        }

        private static bool FillArticleTable()
        {
            Model.ModelCRUD.InsertUpdateDelete("INSERT INTO tblArticle(title,subject,topic,published) Values('First Article in the system',2,2,1)");

            return true;
        }
    }
}
